package com.cloud.springcloud.alibaba.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * There was an unexpected error (type=Internal Server Error, status=500).
 * I/O error on GET request for "http://CLOUD-PAYMENT-SERVICE/payment/get/40":
 * CLOUD-PAYMENT-SERVICE; nested exception is java.net.UnknownHostException: CLOUD-PAYMENT-SERVICE
 * org.springframework.web.client.ResourceAccessException: I/O error on GET request for
 * "http://CLOUD-PAYMENT-SERVICE/payment/get/40": CLOUD-PAYMENT-SERVICE; nested exception
 * is java.net.UnknownHostException: CLOUD-PAYMENT-SERVICE
 *
 * @auther zzyy
 * @create 2020-02-18 17:27
 */
@Configuration
public class ApplicationContextConfig {
    @Bean
    @LoadBalanced  //8001--8002 集群之后 不知道找那个报错上面的错  需要开启负载均衡器
    // LoadBalanced 赋予 RestTemplate 负载均衡的能力  、调用使用的是 RestTemplate
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }
}
